﻿
using Models.Common;
using GateWayCloodService.CloudCenter;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilsORM;
using static Models.Common.EnumDeviceState;
using GateWayCloodService.Data;
using UtilsORM.MySql_IotGateway;

namespace GateWayCloodService.Mq
{
    public class ServiceSendCommandToGateWay
    {


        //public void taskRun()
        //{
        //    Task.Run(() =>
        //    {
        //        while (true)
        //        {
        //            try
        //            {
        //                // if (new UtilRedisHelper().Lock("sendToMQ_pay"))
        //                // { //当多节点时，同时只有一处执行
        //                sendToMQ();
        //                //     new UtilRedisHelper().DelLock("sendToMQ_pay");
        //                // }
        //            }
        //            catch (Exception ex)
        //            {
        //                Console.WriteLine(ex);
        //            }
        //            Thread.Sleep(1000);
        //        }

        //    });
        //}
        /// <summary>
        /// 发送mq指令队列
        /// </summary>
        //public void sendToMQ(iot_device_command_processing item)
        //{
           
        //    try
        //    {
               
        //        //写日志
        //        CommandLogModel commandLogModel = new CommandLogModel();
        //        commandLogModel.guid = item.p_guid.ToString();
        //        commandLogModel.d_guid = item.p_d_guid;
        //        commandLogModel.deviceModelCode = item.p_device_model_code;
        //        commandLogModel.content = item.p_content;
        //        commandLogModel.name = item.p_name;
        //        commandLogModel.key = item.p_key;
        //        commandLogModel.status_remark = "待处理";
        //        commandLogModel.status = 1;
        //        commandLogModel.mqevent = item.p_mqevent;
        //        commandLogModel.gateWayCode = item.p_gateway_code;
        //        commandLogModel.gateWayDeviceGuid = item.p_gateway_deviceguid;
        //        commandLogModel.agreementType = item.p_agreement_type;
        //        commandLogModel.device_remark = item.p_device_remark + " " + item.p_name;
        //        commandLogModel.parameter = item.p_parameter;
        //        commandLogModel.repeatCount = (int)item.p_repeat_count;
        //        commandLogModel.repeatCountInterval = (int)item.p_repeat_count_interval;
        //        commandLogModel.source = item.p_source;


        //        new ServiceCloudDeviceCommand().writeCommandHandleing(commandLogModel);
               
        //        new ServiceSendMQ().sendCommandToGateWay(commandLogModel);
               
               
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine(ex.ToString());
        //    }
        //}
    }
}
